Bitwise Left Shift (<<) Operator Syntax

The syntax for the bitwise left shift operator is simple:

result = operand1 << operand2;

Here,

  • operand1 is the value whose bits are to be shifted, and
  • operand2 is the number of positions by which the bits are to be shifted.

Bitwise Left Shift(<<) Operator in Programming

Bitwise operators play a significant role in manipulating individual bits within binary data. Among these operators, the Bitwise Left Shift (<<) operator is used for shifting the bits of a number to the left by a specified number of positions. In this blog post, we’ll explore the definition, syntax, examples, and optimization techniques associated with the bitwise left shift operator.

Table of Content

  • What is Bitwise Left Shift (<<) Operator
  • Bitwise Left Shift (<<) Operator Syntax
  • Bitwise Left Shift (<<) Operator in C
  • Bitwise Left Shift (<<) Operator in C++
  • Bitwise Left Shift (<<) Operator in Java
  • Bitwise Left Shift (<<) Operator in Python
  • Bitwise Left Shift (<<) Operator in C#
  • Bitwise Left Shift (<<) Operator in Javascript
  • Bitwise Left Shift (<<) Operator Use Cases

Similar Reads

What is Bitwise Left Shift (<<) Operator:

Bitwise left shift operator (<<) is used to shift the bits of the left operand to the left by the number of positions specified by the right operand. In other words, it moves the bits to the left by a certain number of positions....

Bitwise Left Shift (<<) Operator Syntax:

The syntax for the bitwise left shift operator is simple:...

Bitwise Left Shift (<<) Operator in C:

C #include   int main() {     int x = 5;     int y = x << 2;       printf("Value of x after left shift by 2 positions: %u\n", y);       return 0; }...

Bitwise Left Shift (<<) Operator in C++:

...

Bitwise Left Shift (<<) Operator in Java:

C++ #include using namespace std;   int main() {     int x = 5;     int y = x << 2;       cout << "Value of x after left shift by 2 positions: "          << y << endl;       return 0; }...

Bitwise Left Shift (<<) Operator in Python:

...

Bitwise Left Shift (<<) Operator in C#:

Java /*package whatever //do not write package name here */   import java.io.*;   class GFG {     public static void main(String[] args)     {         int x = 5;         int y = x << 2;           System.out.println("Value of x after left shift by 2 positions: " + y);     } }...

Bitwise Left Shift (<<) Operator in Javascript:

...

Bitwise Left Shift (<<) Operator Use Cases:

Python3 x = 5  # x is an unsigned integer y = x << 2  # Left shift x by 2 positions   print("Value of x after left shift by 2 positions:", y)...